//    Copyright (C) Kherty.  All rights reserved.
using System;

namespace OpenLS.Spreadsheet.AnalysisToolPak
{
     static class ComplexMath
    {
        private static Complex Log(Complex z)
        {
            return Complex.FromPolar(Math.Log(z.Module), z.Theta, z.Suffix);
        }


        public static Complex Cosine(Complex z)
        {
            return new Complex(Math.Cos(z.X)*Math.Cosh(z.Y), -Math.Sin(z.X)*Math.Sinh(z.Y), z.Suffix);
        }

        public static Complex Sin(Complex z)
        {
            return new Complex(Math.Sin(z.X)*Math.Cosh(z.Y), Math.Cos(z.X)*Math.Sinh(z.Y), z.Suffix);
        }

        public static Complex Exp(Complex z)
        {
            return Complex.FromPolar(Math.Exp(z.X), z.Y, z.Suffix);
        }

        public static Complex Sqrt(Complex z)
        {
            return Complex.FromPolar(Math.Sqrt(z.Module), z.Theta/2, z.Suffix);
        }

        public static Complex Pow(Complex z, double number)
        {
            return Complex.FromPolar(Math.Pow(z.Module, number), z.Theta*number, z.Suffix);
        }

        public static Complex LogBase(Complex z, double newBase)
        {
            return Complex.FromPolar(Math.Log(z.Module, newBase), z.Theta, z.Suffix);
        }

         public static Complex Ln(Complex inumber)
         {
             return new Complex(Math.Log(inumber.Module), Math.Atan2(inumber.Imaginary, inumber.Real), inumber.Suffix);
         }
    }
}